<!--
 * @Description: 过滤器
 * @Author: zzj
 * @Date: 2021-10-12 11:46:37
 * @LastEditors: zzj
 * @LastEditTime: 2021-10-12 20:43:32
-->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>过滤器</title>
	<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.js"></script>
</head>
<body>
	<div id="app">
		<div>时间戳：{{time}}</div>
		<div>format转换时间：{{now}}</div>
		<div>filter转换时间：{{time | formatTime }}</div>
		<div>filter转换时间复用：{{time | formatDate }}</div>
	</div>
	<script>
		let briupList = {

		}
		//全局注册
		Vue.filter("formatTime",function(val){
			return moment(val).format("YYYY-MM-DD hh:mm")
		})
		Vue.filter("formatDate", function (val) {
				return moment(val).format("YYYY-MM-DD")
			})

		new Vue({
			el:"#app",
			data:{
				time:new Date().getTime(),
			},
			computed:{
				now:function(){
					//转换
					return moment(this.time).format("YYYY-MM-DD hh:mm")
				}
			},
		})
	</script>
</body>
</html>